﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Core.Sdk.WeiXin.Domain.store
{

    /// <summary>
    /// 小微商户进件申请
    /// </summary>
    public class SmallStoreRequest
    {
        #region 必填
        /// <summary>
        /// 固定版本号为3.0
        /// </summary>
        public string version { get; set; } = "3.0";
        /// <summary>
        /// 平台证书序列号
        /// </summary>
        public string cert_sn { get; set; }
        /// <summary>
        /// 服务商的商户号
        /// </summary>
        public string mch_id { get; set; }
        /// <summary>
        /// 随机字符串
        /// </summary>
        public string nonce_str { get; set; }
        /// <summary>
        /// 签名类型，仅支持HMAC-SHA256 
        /// </summary>
        public string sign_type { get; set; } = "HMAC-SHA256";
        /// <summary>
        /// 签名
        /// </summary>
        public string sign { get; set; }
        /// <summary>
        /// 业务申请编号(小微商户的唯一标识，由服务商指定)
        /// </summary>
        public string business_code { get; set; }
        /// <summary>
        /// 身份证正面照
        /// </summary>
        public string id_card_copy { get; set; }
        /// <summary>
        /// 身份证反面照
        /// </summary>
        public string id_card_national { get; set; }
        /// <summary>
        /// 身份证姓名
        /// </summary>
        public string id_card_name { get; set; }
        /// <summary>
        /// 身份证号码
        /// </summary>
        public string id_card_number { get; set; }
        /// <summary>
        /// 身份证有效期
        /// </summary>
        public string id_card_valid_time { get; set; }
        /// <summary>
        /// 开户名称
        /// </summary>
        public string account_name { get; set; }
        /// <summary>
        /// 开户银行
        /// </summary>
        public string account_bank { get; set; }
        /// <summary>
        /// 开户银行省市编码
        /// </summary>
        public string bank_address_code { get; set; }
        /// <summary>
        /// 银行账号
        /// </summary>
        public string account_number { get; set; }
        /// <summary>
        /// 商户简称,最多16个汉字长度
        /// </summary>
        public string merchant_shortname { get; set; }
        /// <summary>
        /// 门店名称
        /// </summary>
        public string store_name { get; set; }
        /// <summary>
        /// 门店省市编码
        /// </summary>
        public string store_address_code { get; set; }
        /// <summary>
        /// 门店街道名称
        /// </summary>
        public string store_street { get; set; }
        /// <summary>
        /// 门店门口照片
        /// </summary>
        public string store_entrance_pic { get; set; }
        /// <summary>
        /// 店内环境照片
        /// </summary>
        public string indoor_pic { get; set; }
        /// <summary>
        /// 客服电话
        /// </summary>
        public string service_phone { get; set; }
        /// <summary>
        /// 售卖商品/提供服务描述(填写以下描述之一：餐饮、线下零售、居民生活服务、休闲娱乐、交通出行、其他)
        /// </summary>
        public string product_desc { get; set; }
        /// <summary>
        /// 费率
        /// </summary>
        public string rate { get; set; } = "0.38%";

        /// <summary>
        /// 联系人姓名(和身份证姓名一致,需加密处理)
        /// </summary>
        public string contact { get; set; }
        /// <summary>
        /// 手机号码(需加密处理)
        /// </summary>
        public string contact_phone { get; set; }
        /// <summary>
        /// 联系邮箱
        /// </summary>
        public string contact_email { get; set; } = "";
        #endregion

        #region 选填
        /// <summary>
        /// 开户银行全称（含支行）
        /// </summary>
        public string bank_name { get; set; } = "";
        ///// <summary>
        ///// 门店经度
        ///// </summary>
        //public string store_longitude { get; set; } = "";
        ///// <summary>
        ///// 门店纬度
        ///// </summary>
        //public string store_latitude { get; set; } = "";
        ///// <summary>
        ///// 经营场地证明图片
        ///// </summary>
        //public string address_certification { get; set; } = "";
        ///// <summary>
        ///// 补充说明
        ///// </summary>
        //public string business_addition_desc { get; set; } = "";
        ///// <summary>
        ///// 补充材料（最多上传5张照片，格式：["123","456"]）
        ///// </summary>
        //public string business_addition_pics { get; set; } = "";

        #endregion
    }

    public class SpecialStoreOut
    {
        public string code { get; set; }
        /// <summary>
        /// 错误消息
        /// </summary>
        public string message { get; set; } = "";

        #region 成功才返回
        public string applyment_id { get; set; } = "";
        #endregion
    }

    /// <summary>
    /// 特约商户入参
    /// </summary>
    public class SpecialStoreIn
    {
        /// <summary>
        /// 业务申请编号
        /// 1、服务商自定义的唯一编号。
        ///2、每个编号对应一个申请单，每个申请单审核通过后会生成一个微信支付商户号。
        ///3、若申请单被驳回，可填写相同的“业务申请编号”，即可覆盖修改原申请单信息。
        /// </summary>
        public string business_code { get; set; }
        /// <summary>
        /// 管理员
        /// </summary>
        public StoreAdmin contact_info { get; set; }
        /// <summary>
        /// 主体资料
        /// </summary>
        public StoreSubject subject_info { get; set; }
        /// <summary>
        /// 经营资料
        /// </summary>
        public StoreBusiness business_info { get; set; }
        /// <summary>
        /// 结算规则
        /// </summary>
        public StoreSettlement settlement_info { get; set; }
        /// <summary>
        /// 银行账号
        /// </summary>
        public StoreBank bank_account_info { get; set; }
    }

    /// <summary>
    /// 管理员
    /// </summary>
    public class StoreAdmin
    {
        /// <summary>
        /// 管理员姓名
        /// </summary>
        public string contact_name { get; set; }
        /// <summary>
        /// 管理员身份证件号码
        /// </summary>
        public string contact_id_number { get; set; }
        /// <summary>
        /// 管理员微信openid
        /// </summary>
        public string openid { get; set; }
        /// <summary>
        /// 联系手机
        /// </summary>
        public string mobile_phone { get; set; }
        /// <summary>
        /// 联系邮箱
        /// </summary>
        public string contact_email { get; set; }
    }
    /// <summary>
    /// 主体资料
    /// </summary>
    public class StoreSubject
    {
        /// <summary>
        /// 主体类型
        /// SUBJECT_TYPE_INDIVIDUAL（个体户）
        ///SUBJECT_TYPE_ENTERPRISE（企业）：
        ///SUBJECT_TYPE_INSTITUTIONS（党政、机关及事业单位,如：公安、党团、司法、交通、旅游、工商税务、市政、医疗、教育、学校等机构）
        ///SUBJECT_TYPE_OTHERS（其他组织,如社会团体、民办非企业、基金会)
        /// </summary>
        public string subject_type { get; set; }
        /// <summary>
        /// 营业执照
        /// </summary>
        public StoreLicense business_license_info { get; set; }
        /// <summary>
        /// 法人资料
        /// </summary>
        public StoreIdentity identity_info { get; set; }

        ///// <summary>
        ///// 登记证书(选填)
        ///// </summary>
        //public object certificate_info { get; set; }
        ///// <summary>
        ///// 组织机构代码证(选填)
        ///// </summary>
        //public object organization_info { get; set; }
        ///// <summary>
        ///// 单位证明函照片(选填)
        ///// </summary>
        //public string certificate_letter_copy { get; set; }
    }
    /// <summary>
    /// 经营资料
    /// </summary>
    public class StoreLicense
    {
        /// <summary>
        /// 营业执照照片(上传彩色照片or彩色扫描件or复印件（需加盖公章鲜章），可添加“微信支付”相关水印（如微信支付认证）)
        /// </summary>
        public string license_copy { get; set; }
        /// <summary>
        /// 注册号/统一社会信用代码
        /// </summary>
        public string license_number { get; set; }
        /// <summary>
        /// 营业执照上的商户名称(1.个体户不能以“公司”结尾；2.个体户若营业执照上商户名称为“空“或“无”时，填写"个体户+经营者姓名"，如“个体户张三”)
        /// </summary>
        public string merchant_name { get; set; }
        /// <summary>
        /// 个体户经营者/法人姓名
        /// </summary>
        public string legal_person { get; set; }
    }

    public class StoreSettlement
    {
        /// <summary>
        /// 入驻结算规则ID( 719: 个体户(费率0.6%,T+1结算日); 716: 企业(费率0.6%,T+1结算日))
        /// </summary>
        public string settlement_id { get; set; }
        /// <summary>
        /// 行业(餐饮、零售批发、交通出行、生活娱乐服务、培训教育机构、民营医疗机构、代理缴纳话费等业务)
        /// </summary>
        public string qualification_type { get; set; }
        /// <summary>
        /// 特殊资质图片,最多5张
        /// </summary>
        public List<string> qualifications { get; set; }
        /// <summary>
        /// 优惠费率活动ID，如：20191030111cff5b5e
        /// </summary>
        public string activities_id { get; set; }
        /// <summary>
        /// 优惠费率活动值,如： 0.2
        /// </summary>
        public string activities_rate { get; set; }
    }
    public class StoreBank
    {
        /// <summary>
        /// 账号类型：BANK_ACCOUNT_TYPE_CORPORATE：对公银行账户，BANK_ACCOUNT_TYPE_PERSONAL：个人银行卡
        /// </summary>
        public string bank_account_type { get; set; }
        /// <summary>
        /// 开户名称    
        /// </summary>
        public string account_name { get; set; }
        /// <summary>
        /// 开户银行
        /// </summary>
        public string account_bank { get; set; }
        /// <summary>
        /// 银行账号
        /// </summary>
        public string account_number { get; set; }
        /// <summary>
        /// 开户银行省市编码（精确到市）
        /// </summary>
        public string bank_address_code { get; set; }
        /// <summary>
        /// 开户银行全称（含支行）
        /// </summary>
        public string bank_name { get; set; }
    }

    public class StoreBusiness
    {
        /// <summary>
        /// 商户简称
        /// </summary>
        public string merchant_shortname { get; set; }
        /// <summary>
        /// 客服电话
        /// </summary>
        public string service_phone { get; set; }
        /// <summary>
        /// 经营场景
        /// </summary>

        public StoreSales sales_info { get; set; }
    }
    /// <summary>
    /// 经营场景
    /// </summary>
    public class StoreSales
    {
        /// <summary>
        /// 经营场景类型
        /// SALES_SCENES_STORE：线下门店
        /// SALES_SCENES_MP：公众号
        /// SALES_SCENES_MINI_PROGRAM：小程序
        /// SALES_SCENES_WEB：互联网
        /// SALES_SCENES_APP：APP
        /// SALES_SCENES_WEWORK：企业微信
        /// </summary>
        public List<string> sales_scenes_type { get; set; }
        public StoreMp mp_info { get; set; }
    }

    public class StoreMp
    {
        /// <summary>
        /// 服务商小程序APPID
        /// </summary>
        public string mp_appid { get; set; } = "";
        public string mp_sub_appid { get; set; } = "";
        public List<string> mp_pics { get; set; } = new List<string>();
    }
    
    /// <summary>
    /// 法人证件
    /// </summary>
    public class StoreIdentity
    {
        /// <summary>
        /// 证件类型: IDENTIFICATION_TYPE_IDCARD 大陆身份证
        /// </summary>
        public string id_doc_type { get; set; } = "IDENTIFICATION_TYPE_IDCARD";
        public StoreIdCard id_card_info { get; set; }
        public bool owner { get; set; } = true;
    }

    /// <summary>
    /// 身份证
    /// </summary>
    public class StoreIdCard
    {
        /// <summary>
        /// 身份证正面
        /// </summary>
        public string id_card_copy { get; set; }
        /// <summary>
        /// 身份证反面
        /// </summary>
        public string id_card_national { get; set; }
        /// <summary>
        /// 姓名
        /// </summary>
        public string id_card_name { get; set; }
        /// <summary>
        /// 身份证号
        /// </summary>
        public string id_card_number { get; set; }
        /// <summary>
        /// 开始时间
        /// </summary>
        public string card_period_begin { get; set; }
        /// <summary>
        /// 截止时间
        /// </summary>
        public string card_period_end { get; set; }
    }
}